package pe.com.cotelasa.common.validator;

import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.FacesValidator;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;

import org.apache.log4j.Logger;

@FacesValidator("selectOneMenuFormularioValidator")
public class SelectOneMenuFormularioValidator implements Validator{

	private static Logger logger = Logger.getLogger(SelectOneMenuFormularioValidator.class);
	
	@Override
	public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
		if(value.equals(new Integer(0)) || value.equals("0")){
			FacesMessage msg = new FacesMessage("Este campo es requerido", "Este campo es requerido");
			msg.setSeverity(FacesMessage.SEVERITY_ERROR);
			throw new ValidatorException(msg);
		}
		
	}


}
